<template>
  <div class="login">
    <div class="container">
      <a href="/#/index">
        <img src="/imgs/login-logo.png" alt />
      </a>
    </div>
    <div class="wrapper">
      <div class="container">
        <div class="login-form">
          <h3>
            <span class="checked">账号登录</span>
            <span class="sep-line">|</span>
            <span>扫码登录</span>
          </h3>
          <div class="input">
            <input type="text" placeholder="请输入账号" v-model="username" />
          </div>
          <div class="input">
            <input type="password" placeholder="请输入密码" v-model="password" @keyup.enter.stop="login" />
          </div>
          <div class="btn-box">
              <a href="javascript:;" class="btn" @click="login">登录</a>
          </div>
          <div class="tips">
              <div class="sms">
                  手机短信登录/注册
              </div>
              <div class="reg">
                  立即注册<span>|</span>忘记密码？
              </div>
          </div>
        </div>
      </div>
    </div>
    <nav-footer></nav-footer>
  </div>
</template>

<script>
import NavFooter from '../components/NavFooter'
export default {
  name: "login",
  data() {
    return {
      username:'',
      password:'',
      userId:''
    };
  },
  components: {
      NavFooter
  },
  methods: {
    login(){
      let {username,password} = this;
      this.axios.post('/user/login',{
        username,
        password
      }).then((res)=>{
        this.$cookie.set('userId',res.id,{expires:'Session'});
        //to - do 保存用户名
        this.$store.dispatch('saveUserName',res.username);
        this.$router.push({
          name:'index',
          params:{
            from:'login'
          }
        })
      })
    }
  }
};
</script>

<style lang="scss" scoped>
@import "../assets/scss/mixin.scss";
@import "../assets/scss/config.scss";
.login {
  .container {
    a {
      img {
        width: 231px;
        height: 113px;
      }
    }
  }
  .wrapper {
    background: url("/imgs/login-bg.jpg") no-repeat 50%;
    .container {
      height: 576px;
      .login-form {
        box-sizing: border-box;
        padding-left: 31px;
        padding-right: 31px;
        width: 410px;
        height: 510px;
        background-color: #fff;
        position: absolute;
        bottom: 29px;
        right: 0;
        h3{
            font-size: 24px;
            line-height: 24px;
            text-align: center;
            margin: 40px auto 49px;
            .checked{
                color: $colorA;
            }
            .sep-line{
                margin: 0 32px;
            }
        }
        .input{
            border: 1px solid #e5e5e5;
            margin-bottom: 25px;
            input{
                width:100%;
                height: 50px;
                line-height: 50px;
                padding-left: 20px;
                border: none;
                box-sizing: border-box;
            }
        }
        .btn-box{
            width: 100%;
            .btn{
                width: 100%;
                height: 50px;
                line-height: 50px;
                font-size: 18px;
            }
        }
        .tips{
            margin-top: 14px;
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            cursor:pointer;
            font-size: 14px;
            .sms{
                color:$colorA;
            }
            .reg{
                color: #999;
                span{
                    margin: 0 7px;
                    
                }
            }
        }
      }
    }
  }
}
</style>
